package edu.neusoft.springhtmldemo.mapper;

import edu.neusoft.springhtmldemo.domain.DatasubStationManagement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DatasubStationManagementMapper {
    @Select("select * from datastationmanagemententity")
    List<DatasubStationManagement> selectAll();

    @Select("update datastationmanagemententity " +
            "set datastationName=#{datastationName},datastationIP=#{datastationIP},datastationLocation=#{datastationLocation} " +
            "where datastationID=#{datastationID}")
    void updateDatasubStation(DatasubStationManagement management);

    @Select("select * from datastationmanagemententity\n" +
            "where datastationID like '%' #{datastationID} '%'\n" +
            "and datastationName like '%' #{datastationName} '%'\n" +
            "and datastationIP like '%' #{datastationIP} '%'\n" +
            "and datastationLocation like '%' #{datastationLocation} '%'")
    List<DatasubStationManagement> selectDatasubStationManagement(String datastationID,String datastationName,String datastationIP,String datastationLocation);

    @Select("INSERT into datastationmanagemententity(datastationName,datastationIP,datastationLocation)\n" +
            "value(#{datastationName},#{datastationIP},#{datastationLocation})")
    void addDatasubStationManagement(DatasubStationManagement management);

    @Select("delete from datastationmanagemententity where datastationID in (#{datastationID})")
    void delDatasubStationManagement(Integer datastationID);

    @Select("SELECT datastationIP from datastationmanagemententity")
    List<String> datastationIPValues();

    @Select("SELECT datastationName from datastationmanagemententity where datastationIP=#{datastationIP}")
    String datastationNameValue(String datastationIP);
}
